﻿// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
// This is sample code only, do not use in production environments
namespace Microsoft.ALMRangers.TfsTeams
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    public static class Program
    {
        public static void Main(string[] args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            if (!args.Any())
            {
                ShowUsageCommand cmd = new ShowUsageCommand();
                cmd.Run();
            }
            else
            {
                CommandBase cmd;
                switch (args[0].ToUpper())
                {
                    case "LISTTEAMS":
                        cmd = new ListTeamCommand();
                        break;
                    case "CREATETEAM":
                        cmd = new CreateTeamCommand();
                        break;
                    case "ADDUSER":
                        cmd = new AddUserCommand();
                        break;
                    default:
                        cmd = new ShowUsageCommand();
                        break;
                }

                List<string> lstArg = new List<string>();
                lstArg.AddRange(args);
                lstArg.RemoveAt(0);

                if (cmd.ParseArguments(lstArg.ToArray()))
                {
                    if (cmd.Validate())
                    {
                        cmd.Run();
                    }
                }
            }
        }
    }
}
